use std::fs;
use tracing::info;

pub fn setup_user_namespace(pid: u32) -> anyhow::Result<()> {
    info!("Setting up user namespace...");

    fs::write(format!("/proc/{}/setgroups", pid), "deny\n")?;
    fs::write(format!("/proc/{}/uid_map", pid), "0 0 1\n")?;
    fs::write(format!("/proc/{}/gid_map", pid), "0 0 1\n")?;
    Ok(())
}